import {apiStartExam} from "@/api/exam/exam.js";
export default {
    data() {
        return {
            pageName:"混入页面",
			practiceId:"",
			examStatus:""
        }
    },
    onShow() {

    },
	onLoad(options){
		this.practiceId = options.practiceId ? options.practiceId : 23;
		this.examStatus =  options.examStatus ? options.examStatus : 1;
	},
    methods: {
		startExam(actionName){
			let prams = {'practiceId':this.practiceId};
			this.$tip.loading();
			apiStartExam(prams).then((res)=>{
				if(+res.code == 200){
					this.$tip.loaded();
					res.data.titleName = "GRE" + res.data.practiceType + res.data.practiceName;
					this.$store.dispatch('changeExamInfoData',res.data);
					if(this.examStatus == 0){ //开始考试
						if(+res.data.practiceMode == 1){   //单科1
							uni.redirectTo({
								url: "/pages/exam/chineseSection?recordId="+res.data.recordId+"&currentTopicId="+res.data.currentTopicId
							});
						}else{  //整套2
							uni.redirectTo({
								url: "/pages/exam/examTip"
							});
						}
					}else{ //继续考试 不进入靠前提示页面
						this.$store.dispatch('changeExamDuration',res.data.duration);
						if(+res.data.practiceMode == 1){ //单科
							uni.redirectTo({
								url: "/pages/exam/chineseSection?recordId="+res.data.recordId+"&currentTopicId="+res.data.currentTopicId
							});
							
						}else{ //整套
							if(this.practiceStatus == 2){ //重新作答
								uni.redirectTo({
									url: "/pages/exam/examTip"
								});
							}else{ // 1 3  语文    || 2 4 数学
								if(res.data.currentTopicStatus == 0){ //未浏览第一题
									if( +res.data.sectionType == 1 || +res.data.sectionType == 3){  //currentTopicOrder == 1&&sectionType 进入某个说明页面
										uni.redirectTo({
											url: "/pages/exam/chineseExplain"
										});
									}
									if(+res.data.sectionType == 2 || +res.data.sectionType == 4 ){  //currentTopicOrder == 1&&sectionType 进入某个说明页面
										uni.redirectTo({
											url: "/pages/exam/mathExplain"
										});
									}
								}else{
									uni.redirectTo({
										url: "/pages/exam/chineseSection?recordId="+res.data.recordId+"&currentTopicId="+res.data.currentTopicId
									});
									
								}
							}	
						}
					}	
				}else{
					this.$tip.toast(res.msg);
				}
			}).catch((error)=>{
				this.$tip.toast(error.msg);
			})
		}

    },
    onHide() {

    },
    onUnload() {

    }
}